#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	for (int i = 0;i<N;i++)
	{
		for(int t = 0;t<=3;t++)
		{
			int cnt = 1;
		    char a,b;
		    scanf("%c-%c",&a,&b);
			
			if(b=='T'){printf("%d",cnt);break;}
			
			cnt++;
		}
	}
	return 0;
}
